home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3baudiodoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  7.5 KB  |  264 lines

  1. /* 
  2.  *
  3.  * $Id: k3baudiodoc.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BAUDIODOC_H
  18. #define K3BAUDIODOC_H
  19.  
  20. #include <k3bdoc.h>
  21.  
  22. #include <k3bcdtext.h>
  23. #include <k3btoc.h>
  24.  
  25. #include <qptrlist.h>
  26. #include <qfile.h>
  27. #include <qstring.h>
  28. #include <qstringlist.h>
  29. #include <qdatetime.h>
  30. #include <qtextstream.h>
  31. #include "k3b_export.h"
  32. #include <kurl.h>
  33.  
  34. class K3bApp;
  35. class K3bAudioTrack;
  36. class QWidget;
  37. class QTimer;
  38. class QDomDocument;
  39. class QDomElement;
  40. class K3bThreadJob;
  41. class KConfig;
  42. class K3bAudioDataSource;
  43. class K3bAudioDecoder;
  44. class K3bAudioFile;
  45.  
  46. /**Document class for an audio project. 
  47.  *@author Sebastian Trueg
  48.  */
  49.  
  50. class LIBK3B_EXPORT K3bAudioDoc : public K3bDoc  
  51. {
  52.   Q_OBJECT
  53.  
  54.   friend class K3bMixedDoc;
  55.   friend class K3bAudioTrack;
  56.   friend class K3bAudioFile;
  57.     
  58.  public:
  59.   K3bAudioDoc( QObject* );
  60.   ~K3bAudioDoc();
  61.  
  62.   QString name() const;
  63.     
  64.   bool newDocument();
  65.  
  66.   bool hideFirstTrack() const { return m_hideFirstTrack; }
  67.   int numOfTracks() const;
  68.  
  69.   bool normalize() const { return m_normalize; }
  70.  
  71.   K3bAudioTrack* firstTrack() const;
  72.   K3bAudioTrack* lastTrack() const;
  73.  
  74.   /**
  75.    * Slow.
  76.    * \return the K3bAudioTrack with track number trackNum starting at 1 or 0 if trackNum > numOfTracks()
  77.    */
  78.   K3bAudioTrack* getTrack( unsigned int trackNum );
  79.  
  80.   /**
  81.    * Creates a new audiofile inside this doc which has no track yet.
  82.    */
  83.   K3bAudioFile* createAudioFile( const KURL& url );
  84.  
  85.   /** get the current size of the project */
  86.   KIO::filesize_t size() const;
  87.   K3b::Msf length() const;
  88.     
  89.   // CD-Text
  90.   bool cdText() const { return m_cdText; }
  91.   const QString& title() const { return m_cdTextData.title(); }
  92.   const QString& artist() const { return m_cdTextData.performer(); }
  93.   const QString& disc_id() const { return m_cdTextData.discId(); }
  94.   const QString& arranger() const { return m_cdTextData.arranger(); }
  95.   const QString& songwriter() const { return m_cdTextData.songwriter(); }
  96.   const QString& composer() const { return m_cdTextData.composer(); }
  97.   const QString& upc_ean() const { return m_cdTextData.upcEan(); }
  98.   const QString& cdTextMessage() const { return m_cdTextData.message(); }
  99.  
  100.   /**
  101.    * Create complete CD-Text including the tracks' data.
  102.    */
  103.   K3bDevice::CdText cdTextData() const;
  104.  
  105.   int audioRippingParanoiaMode() const { return m_audioRippingParanoiaMode; }
  106.   int audioRippingRetries() const { return m_audioRippingRetries; }
  107.   bool audioRippingIgnoreReadErrors() const { return m_audioRippingIgnoreReadErrors; }
  108.  
  109.   /**
  110.    * Represent the structure of the doc as CD Table of Contents.
  111.    */
  112.   K3bDevice::Toc toToc() const;
  113.  
  114.   K3bBurnJob* newBurnJob( K3bJobHandler*, QObject* parent = 0 );
  115.  
  116.   /**
  117.    * Shows dialogs.
  118.    */
  119.   void informAboutNotFoundFiles();
  120.   
  121.   /**
  122.    * returns the new after track, ie. the the last added track or null if
  123.    * the import failed.
  124.    *
  125.    * This is a blocking method.
  126.    *
  127.    * \param cuefile The Cuefile to be imported
  128.    * \param after   The track after which the new tracks should be inserted
  129.    * \param decoder The decoder to be used for the new tracks. If 0 a new one will be created.
  130.    *
  131.    * BE AWARE THAT THE DECODER HAS TO FIT THE AUDIO FILE IN THE CUE.
  132.    */
  133.   K3bAudioTrack* importCueFile( const QString& cuefile, K3bAudioTrack* after, K3bAudioDecoder* decoder = 0 );
  134.  
  135.   /**
  136.    * Create a decoder for a specific url. If another AudioFileSource with this
  137.    * url is already part of this project the associated decoder is returned.
  138.    *
  139.    * In the first case the decoder will not be initialized yet (K3bAudioDecoder::analyseFile
  140.    * is not called yet).
  141.    *
  142.    * \param url The url for which a decoder is requested.
  143.    * \param reused If not null this variable is set to true if the decoder is already in
  144.    *               use and K3bAudioDecoder::analyseFile() does not have to be called anymore.
  145.    */
  146.   K3bAudioDecoder* getDecoderForUrl( const KURL& url, bool* reused = 0 );
  147.  
  148.   static bool readPlaylistFile( const KURL& url, KURL::List& playlist );
  149.  
  150.  public slots:
  151.   void addUrls( const KURL::List& );
  152.   void addTrack( const KURL&, uint );
  153.   void addTracks( const KURL::List&, uint );
  154.   /** 
  155.    * Adds a track without any testing 
  156.    *
  157.    * Slow because it uses getTrack.
  158.    */
  159.   void addTrack( K3bAudioTrack* track, uint position = 0 );
  160.  
  161.   void addSources( K3bAudioTrack* parent, const KURL::List& urls, K3bAudioDataSource* sourceAfter = 0 );
  162.  
  163.   void removeTrack( K3bAudioTrack* );
  164.   void moveTrack( K3bAudioTrack* track, K3bAudioTrack* after );
  165.  
  166.   void setHideFirstTrack( bool b ) { m_hideFirstTrack = b; }
  167.   void setNormalize( bool b ) { m_normalize = b; }
  168.  
  169.   // CD-Text
  170.   void writeCdText( bool b ) { m_cdText = b; }
  171.   void setTitle( const QString& v );
  172.   void setArtist( const QString& v );
  173.   void setPerformer( const QString& v );
  174.   void setDisc_id( const QString& v );
  175.   void setArranger( const QString& v );
  176.   void setSongwriter( const QString& v );
  177.   void setComposer( const QString& v );
  178.   void setUpc_ean( const QString& v );
  179.   void setCdTextMessage( const QString& v );
  180.  
  181.   // Audio-CD Ripping
  182.   void setAudioRippingParanoiaMode( int i ) { m_audioRippingParanoiaMode = i; }
  183.   void setAudioRippingRetries( int r ) { m_audioRippingRetries = r; }
  184.   void setAudioRippingIgnoreReadErrors( bool b ) { m_audioRippingIgnoreReadErrors = b; }
  185.  
  186.   void removeCorruptTracks();
  187.  
  188.  private slots:
  189.   void slotTrackChanged( K3bAudioTrack* );
  190.   void slotTrackRemoved( K3bAudioTrack* );
  191.  
  192.  signals:
  193.   void trackChanged( K3bAudioTrack* );
  194.   void trackRemoved( K3bAudioTrack* );
  195.  
  196.  protected:
  197.   /** reimplemented from K3bDoc */
  198.   bool loadDocumentData( QDomElement* );
  199.   /** reimplemented from K3bDoc */
  200.   bool saveDocumentData( QDomElement* );
  201.  
  202.   QString typeString() const;
  203.  
  204.  private:
  205.   // the stuff for adding files
  206.   // ---------------------------------------------------------
  207.   K3bAudioTrack* createTrack( const KURL& url );
  208.  
  209.   /**
  210.    * Handle directories and M3u files
  211.    */
  212.   KURL::List extractUrlList( const KURL::List& urls );
  213.   // ---------------------------------------------------------
  214.  
  215.   /**
  216.    * Used by K3bAudioTrack to update the track list
  217.    */
  218.   void setFirstTrack( K3bAudioTrack* track );
  219.   /**
  220.    * Used by K3bAudioTrack to update the track list
  221.    */
  222.   void setLastTrack( K3bAudioTrack* track );
  223.  
  224.   /**
  225.    * Used by K3bAudioFile to tell the doc that it does not need the decoder anymore.
  226.    */
  227.   void decreaseDecoderUsage( K3bAudioDecoder* );
  228.   void increaseDecoderUsage( K3bAudioDecoder* );
  229.  
  230.   K3bAudioTrack* m_firstTrack;
  231.   K3bAudioTrack* m_lastTrack;
  232.      
  233.   bool m_hideFirstTrack;
  234.   bool m_normalize;
  235.  
  236.   KURL::List m_notFoundFiles;
  237.   KURL::List m_unknownFileFormatFiles;
  238.  
  239.   // CD-Text
  240.   // --------------------------------------------------
  241.   K3bDevice::CdText m_cdTextData;
  242.   bool m_cdText;
  243.   // --------------------------------------------------
  244.  
  245.   // Audio ripping
  246.   int m_audioRippingParanoiaMode;
  247.   int m_audioRippingRetries;
  248.   bool m_audioRippingIgnoreReadErrors;
  249.  
  250.   //
  251.   // decoder housekeeping
  252.   // --------------------------------------------------
  253.   // used to check if we may delete a decoder
  254.   QMap<K3bAudioDecoder*, int> m_decoderUsageCounterMap;
  255.   // used to check if we already have a decoder for a specific file
  256.   QMap<QString, K3bAudioDecoder*> m_decoderPresenceMap;
  257.  
  258.   class Private;
  259.   Private* d;
  260. };
  261.  
  262.  
  263. #endif
  264.